package com.hqyj.javaSpringCloudAccount.dao;

import com.hqyj.entity.account.Menu;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * @author ：Cwd
 * @Description：MenuDao
 * @date ：2021/8/26 11:22
 */
@Mapper
@Repository
public interface MenuDao {

    @Select("select * from account_menu order by parent_id, priority")
    List<Menu> getAllMenus();

    @Select("select * from account_menu am "
            + "left join account_role_menu arm on am.id = arm.menu_id "
            + "left join account_user_role aur on arm.role_id = aur.role_id "
            + "where aur.user_id = #{userId} order by am.parent_id, am.priority")
    List<Menu> getMenusByUserId(int userId);

}